Wandering to a random note

Backlink: ยง2020-04-17-1605 Expansions HUB

Sometimes it’s nice to wander.

The following feature was suggested by erictleung.

In using org-brain, I really liked its wander feature, which brings a note randomly. It essentially randomly samples the notes created and displays it. This can be helpful as an informal ’quiz’ of your knowledge base or at least refresh your memory that the particular note exists. From there you can edit it with current knowledge or link it to other notes.

He proposed a function to do so, which is edited and shared below.

It will pop open the deft buffer, pick a random zetteldeft ID, and enter it as a search string.

(defun zetteldeft-wander ()
  "Wander through `zetteldeft' notes.
Search `deft' for a random `zetteldeft' id."
  (interactive)
  (switch-to-buffer deft-buffer)
  (let ((all-files (deft-find-all-files-no-prefix)))
    (deft-filter
      (zetteldeft--lift-id
        (nth (random (length all-files))
           all-files)))))

Make sure Deft is loaded (with C-c d d), and then run zetteldeft-wander. It will retreive a random file from the Deft list of files, and search for its ID.

One potential issue: when there are Deft notes without an ID, the search term will be nil.